from pyramid.authorization import Allow, Everyone

from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker, scoped_session
"""
scoped_session本质上也是一个方法，它首先通过session工厂创建session对象，然后对session对象进行相应的管理。
scoped session采用的是注册模式。
scoped session算是一个全局变量。
"""

from sqlalchemy import Column, Integer, VARCHAR
from zope.sqlalchemy import register


DBSession = scoped_session(sessionmaker())
register(DBSession)
Base = declarative_base()


class Student(Base):
    __tablename__ = 'student'
    id = Column(Integer, primary_key=True, nullable=False)
    name = Column(VARCHAR(255), unique=True)
    percent = Column(Integer)
